#include <iostream>

using namespace std;

int besti = 0, bestj = 0, i = 0;

int MaxSum(int n, int *a) {
    int sum = 0, b = 0;
    for (int j = 0; j < n; j++) {
        if (b > 0) b += a[j];
        else {
            b = a[j];
            i = j;
        }
        if (b > sum) {
            sum = b;
            besti = i;
            bestj = j;
        }
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
//    int arr[]{-2,11,-4,13,-5,-2};
    cout << MaxSum(6, arr) << endl;
    cout << besti << " " << bestj << endl;

}